from django.db import models

class Province(models.Model):
    code = models.CharField(primary_key=True, max_length=20)
    name = models.CharField(max_length=100)

    class Meta:
        verbose_name = "省份"
        db_table = 'province'

    def __str__(self):
        return f"{self.name}"

class City(models.Model):
    code = models.CharField(primary_key=True, max_length=20)
    name = models.CharField(max_length=100)
    provinceCode = models.ForeignKey(Province, on_delete=models.CASCADE)

    class Meta:
        db_table = 'city'
        verbose_name = "城市"

    def __str__(self):
        return f"{self.name} -- {self.provinceCode}"
